package com.kiln.juxingqs.ui

import androidx.lifecycle.Observer
import client.global.commlib.toast.toast
import com.kiln.juxingqs.BaseMiddleActivity
import com.kiln.juxingqs.R
import com.kiln.juxingqs.api.bean.UserCards
import com.kiln.juxingqs.databinding.ActivityBankmanagerDetailBinding
import com.kiln.juxingqs.dialog.MsgTitleDialog
import com.kiln.juxingqs.ui.vm.BankManagerViewModel

/**
 * Date: 2022/11/3 14:48
 * Description: 银行卡管理
 */
class BankDetailActivity : BaseMiddleActivity<BankManagerViewModel, ActivityBankmanagerDetailBinding>() {

    override fun getLayout(): Int {
        return R.layout.activity_bankmanager_detail
    }

    var bean: UserCards.Card? = null
    override fun initViewModel(): BankManagerViewModel = createViewModel()

    override fun initView() {
        super.initView()
        binding.apply {
            event = this@BankDetailActivity
        }
    }

    override fun initData() {
        super.initData()
        bean= intent.getParcelableExtra<UserCards.Card>("bean")
        binding.e = bean

        viewModel.delRet.observe(this, Observer {
            it?.let {
                if (it.isSuccess) {
                    toast("操作成功")
                    finish()
//                    holdCall()
                }
            }
        })

    }

    fun onUnbindBank() {
        MsgTitleDialog(this).apply {
            okTxt = "确定"
            cancleTxt = "关闭"
            title = "确定要解绑该银行卡吗？"
            ok = {
                viewModel.delCard(bean!!.token_no)
            }
        }.show()

    }

}